//q6.cpp
//This program takes an A,B,C,D for A*x+B*y+C*z=D and a range as N
//Prints the amount of solutions and one of them.
//
//Binyamin 28 december 2017
//===========================================================================
#include<iostream>

using namespace std;

//1. Prompt for the variables.
//2. Capture the variables.
//3. Prompt for range.
//4. Capture range.
//5. circle over the range and count solutions.
//6. Print the amount of solutions and one of them.

int main()
{
	int A,B,C,D; // A-D -  Variables as inseretd by the user
	int N; // N- Range as defined by the user.
	int counter; //counter - a counter for the solutions.
	int x, y, z; // x,y,z - used to store one solution to print out.
	int i,j,k; // i,j,k - loopers for the for loops.

	counter = 0;

	cout << "Please enter A,B,C,D for a A*x+B*y+C*z=D equation" << endl;
	cin >> A >> B >> C >> D;
	cout << "Please enter an N for a range" << endl;
	cin >> N;
	for(i=-1*N/2;i<=N/2;i++)
		for(j=-1*N/2;j<=N/2;j++)
		{
			if((D-A*i-B*j)%C == 0)
				if(((D-A*i-B*j)/C >=-1*N/2) && ((D-A*i-B*j)/C <= N/2))
				{
					counter++;
					x = i;
					y = j;
					z = (D-A*i-B*j)/C;
				}
		}
	cout << "There are " << counter << " solutions." << endl;
	cout << "Where -" << N/2 << "<= x,y,z <=" << N/2 << endl;
	cout << "One being " << '(' << x << ',' << y << ',' << z << ')' << endl;
	return 0;
}
//output
//Please enter A,B,C,D for a A*x+B*y+C*z=D equation
//2 -3 -1 5
//Please enter an N for a range
//4
//There are 6 solutions.
//Where -2<= x,y,z <=2
//One being (2,0,-1)
